<div class="search byclass">
<span>
年级：
<select name="grade">
<option>-----请选择-----</option>
</select>
</span>
<span>
专业：
<select name="major">
<option>-----请选择-----</option>
</select>
</span>
<span>
班级：
<select name="class">
<option>-----请选择-----</option>
</select>
</span>
<button style="margin-top:-10px;" class="btn btn-primary" name="count">统计</button>
</div>

<hr>
<div id="countClass"></div>
<script>
	var grade=document.getElementsByName("grade")[0];
	var major=document.getElementsByName("major")[0];
	var iclass=document.getElementsByName("class")[0];
	var count=document.getElementsByName("count")[0];
	var year=(new Date()).getFullYear();
	var j;
	var opt;
	for(j=0;j<5;j++){
		opt=document.createElement("option");
		opt.value=year-j;
		opt.innerHTML=(year-j)+"级";
		grade.appendChild(opt);
	}
	j=0;
	pure.post({
		dataType:"json",
		data:{},
		async:true,
		url:URL+"Request/getMajorList",
		success:function(data){
			var length=data.length;
			for(j=0;j<length;j++){
				opt=document.createElement("option");
				opt.value=data[j].code;
				opt.innerHTML=data[j].name;
				major.appendChild(opt);
			}
		}
	});
	j=0;
	major.onchange=function(){
		pure.post({
			dataType:"json",
			data:{getmajor:major.value},
			async:false,
			url:URL+"Request/getClassList",
			success:function(data){
				var length=data.length;
				iclass.innerHTML="";
				opt=document.createElement("option");
				opt.innerHTML="-----请选择-----";
				iclass.appendChild(opt);
				for(j=0;j<length;j++){
					opt=document.createElement("option");
					opt.value=data[j].code;
					opt.innerHTML=data[j].name;
					iclass.appendChild(opt);
				}
			}
		});

	}
	count.onclick=function(){
		pure.post({
			dataType:"html",
			data:{getgrade:grade.value,getmajor:major.value,getclass:iclass.value},
			url:URL+"Count/countClass",
			success:function(data){
				document.getElementById("countClass").innerHTML=data;
			}
			
		});
	}
</script>
